package IOperation;

import Book.Book;
import Book.BookList;//引用的公开的类 访问内部的成员  而不是导入公开的数组成员

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: wenxiwen
 * Date: 2022/4/15
 * Time: 10:47
 * Description: No Description
 */
public class Add implements IOperation{

    public void work(BookList bookList) {
        System.out.println("新增图书");

        System.out.println("请输入书名：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        System.out.println("请输入作者：");
        String author = scan.nextLine();
        System.out.println("请输入类型:");
        String type = scan.nextLine();
        System.out.println("请输入价格：");
        int dex = scan.nextInt();

        int index = bookList.getCount();
        Book book = new Book(name,author,type,dex);
        bookList.setBooks(index,book);
        bookList.setCount(index+1);
        System.out.println("添加成功");
     }
}